package cmd

import (
	"gitee.com/crack007/goose"
	"gitee.com/crack007/goose/core/web"
	"gitee.com/crack007/udp-penetrate/src/api/config"
	"gitee.com/crack007/udp-penetrate/src/api/handle"
	"github.com/spf13/cobra"
)

func NewClientCmd() *goose.ModuleBuilder {
	clientApiHandle := handle.NewClientApiHandle()
	httpServerBuilder := web.NewHttpServerBuilder(clientApiHandle)
	httpServerBuilder.EnableDebugFlag().EnableConfigFlag()
	httpServerBuilder.EnablePortFlag(80)
	httpServerBuilder.RegisterFlag(func(cobraCmd *cobra.Command) {
		cobraCmd.PersistentFlags().Uint16VarP(&config.ArgConfig.LocalPort, "localport", "l", 10200, "本地端口")
		cobraCmd.PersistentFlags().Uint32VarP(&clientApiHandle.Uid, "uid", "u", 1, "模拟用户id")
	})
	return goose.NewModuleBuilder(httpServerBuilder).SetName("client").SetDesc("用户端")
}
